import moment from "moment";
//表单配置项
const formItemData = {
  'time': {
    itemConfig: {
      name: 'time'
    },
    elConfig: {
      formType: 'rangTime',
      placeholder: ['开始时间', '结束时间'],
      prefix: '时间',
      disabledDate: (current) => {
        return current && (current > moment().endOf('day') || current < moment().startOf('day').subtract(90, 'days'));
      },
    }
  },
  'orderType': {
    itemConfig: {
      name: 'orderType'
    },
    elConfig: {
      formType: 'Select',
      placeholder: '订单类型',
      options: [
        {label: '快递自发打印', value: '0' },
        {label: '正常包裹', value: '1' },
      ]
    }
  },
  'orderSn': {
    itemConfig: {
      name: 'orderSn'
    },
    elConfig: {
      formType: 'Input',
      placeholder: '关联单据号',
    }
  },
  'payOrderSn': {
    itemConfig: {
      name: 'payOrderSn'
    },
    elConfig: {
      formType: 'Input',
      placeholder: '支付单号',
    }
  },
  'transacFlow': {
    itemConfig: {
      name: 'transacFlow'
    },
    elConfig: {
      formType: 'Input',
      placeholder: '交易流水号',
    }
  },
}

//处理表单数据
export const getFormItem = (optionsData) => {
  const arr = [];
  Object.keys(formItemData).map(v => {
    if(optionsData && optionsData[v]) {
      formItemData[v].elConfig.options = optionsData[v];
    }
    arr.push(formItemData[v]);
  })
  return arr;
}